<?php
class SiteManager_CountryController extends SiteManagerController
{
		
   	public function indexAction() {
		$this->view->countries = Obj_Country::getCountries(true);
		$this->view->regions = Obj_Region::getAllRegions(true);
		$this->view->cities = Obj_City::getAllCities(true);
		$this->view->locations = Obj_Location::getAllLocations(true);
		
		$iPage = intval($this->getRequest()->getParam('page', 1));
   			
		$coutry = (int)$this->getRequest()->getParam('country', null);
		if(isset($coutry) && $coutry > 0){
			$country_objects = Obj_Object::getAllPaginatedObjectsByCondition($iPage, 'objects.CountryID = '.$coutry);
			$this->view->objects = $country_objects;
		}
		
		$region = (int)$this->getRequest()->getParam('region', null);
		if(isset($region) && $region > 0){
			$region_objects = Obj_Object::getAllPaginatedObjectsByCondition($iPage, 'objects.RegionID = '.$region);
			$this->view->objects = $region_objects;
		}
		
		$city = (int)$this->getRequest()->getParam('city', null);
		if(isset($city) && $city > 0){
			$city_objects = Obj_Object::getAllPaginatedObjectsByCondition($iPage, 'objects.CityID = '.$city);
			$this->view->objects = $city_objects;
		}
		
		$location = (int)$this->getRequest()->getParam('location', null);
		if(isset($location) && $location > 0){
			$location_objects = Obj_Object::getAllPaginatedObjectsByCondition($iPage, 'objects.LocationID = '.$location);
			$this->view->objects = $location_objects;
		}
		
    }
    
}